#!/bin/bash
lowcnt=0
restartn=0
for a in {1..100000}
do
  cpuu=$(top -b -n 2 |grep Cpu |tail -n 1 |awk '{print $2}' |sed 's/.[^.]*$//')
  if [ "$cpuu" -lt "9" ]; then
    lowcnt=$[$lowcnt+1]
    if [ "$lowcnt" -gt "3" ]; then
      echo restart
      /root/uam-docker/update-uam.sh
      lowcnt=0
      restartn=$[$restartn+1]
    fi
  else
    lowcnt=0
  fi
  echo use=$cpuu lown=$lowcnt  ren=$restartn
 sleep 60
done


